cmake_minimum_required(VERSION 3.6)
project(flutter_cpp_sdk)

set(CMAKE_CXX_STANDARD 14)

#include_directories(${LIBRARY_3RD_PATH}/rapidjson-1.1.0/include)

# 这个是用于测试的 项目, 用于代替 其他第三方库
add_subdirectory(otherLib)
include_directories(.)
include_directories(App)
set(LIBRARY_Src_list
        BaseDartAPI.cpp
        BaseDartAPI.h
        # 添加需要实现的代码
        App/TestApp.cpp
        App/ClientApp.cpp
        otherLib/ThreadPool.cpp
        )
# 公共的第三方库
set(OBJ_LINK_LIBS other_test_sdk )
if (ANDROID)
    MESSAGE(STATUS "build android ")
    set(LIBRARY_Src_list ${LIBRARY_Src_list} android_log_platform.cpp)
    find_library( # Sets the name of the path variable.
            log-lib
            # Specifies the name of the NDK library that
            # you want CMake to locate.
            log)
    MESSAGE(STATUS "find  ${log-lib}")
    set(OBJ_LINK_LIBS
            ${OBJ_LINK_LIBS}
            #            curl
            #            /Volumes/wd320/wujehy/cproject/test_c/3rd_libs/Android_Release/arm64-v8a/lib/libssl.a
            #            /Volumes/wd320/wujehy/cproject/test_c/3rd_libs/Android_Release/arm64-v8a/lib/libcrypto.a
            c++_shared
            ${log-lib}
            c
            #            pthread
            )

    install(FILES ${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libc++_shared.so
            DESTINATION ${CMAKE_SYSTEM_NAME}/${ANDROID_ABI}
            )
    add_library(${PROJECT_NAME} SHARED ${LIBRARY_Src_list})
elseif (APPLE)
    include(ios.toolchain.cmake)
    #    苹果的日志系统
    set(LIBRARY_Src_list ${LIBRARY_Src_list} apple_log_platform.mm)
    set(OBJ_LINK_LIBS
            ${OBJ_LINK_LIBS}
            multy_core
            #            ssl
            #            crypto
            #            curl
            "-framework Foundation")
    add_library(${PROJECT_NAME} SHARED ${LIBRARY_Src_list})
    set_target_properties(${PROJECT_NAME} PROPERTIES FRAMEWORK TRUE)
endif ()


target_link_libraries(${PROJECT_NAME} PUBLIC ${OBJ_LINK_LIBS})

if (ANDROID)
    install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_SYSTEM_NAME}/${ANDROID_ABI})
elseif (APPLE)
    install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_SYSTEM_NAME}/${PLATFORM} FRAMEWORK DESTINATION ${CMAKE_SYSTEM_NAME}/${PLATFORM})
endif ()

